<%@include file="../../taglibs.jsp" %>
<stripes:layout-render name="../../layout/baseview.jsp">
<stripes:layout-component name="head">
    <jsp:element name="meta">
            <jsp:attribute name="name">
                <c:out value="description"/>
            </jsp:attribute>
            <jsp:attribute name="content">
                <fmt:message key="page.createresume.description"/>
            </jsp:attribute>
    </jsp:element>
    <jsp:element name="meta">
            <jsp:attribute name="name">
                <c:out value="keywords"/>
            </jsp:attribute>
            <jsp:attribute name="content">
                <fmt:message key="page.main.keywords"/>
            </jsp:attribute>
    </jsp:element>
    <title>
        <fmt:message key="page.createresume.title"/>
    </title>

    <script type="text/javascript"
            src="${pageContext.request.contextPath}/ajax/prototype.js"></script>
    <script type="text/javascript" xml:space="preserve">
        function invoke(form, event, container) {
            var params = Form.serialize(form, {submit:event});
            new Ajax.Updater(container, 'Resume.action?updateCities=', {method:'post', parameters:params});
        }
    </script>
</stripes:layout-component>

<jsp:useBean id="dataUtils" class="ua.com.alus.resvac.crm.util.DataUtils" scope="session"/>

<stripes:layout-component name="content">
<br/>
<br/>
<stripes:link href="/resume/Resume.action?listResumes=" class="flowlink">
    <fmt:message key="page.createresume.listresume"/>
</stripes:link>
<br/>
<br/>
<br/>
<stripes:label name="resume.createnewform"/>

<stripes:form id="resumeForm" action="/resume/Resume.action">
<div class="errors">
<stripes:errors globalErrorsOnly="true"/>

<table class="form">
<!-- These fields are needed for updating resume -->
<stripes:hidden name="resume.uuid"/>
<stripes:hidden name="resume.accountUUID"/>

<!--birth year -->
<tr>
    <td>
        <stripes:label name="labelBirthYear"/>
    </td>
    <td>
        <stripes:select name="resume.year">
            <stripes:option value="">
                <fmt:message key="page.createresume.choose"/>
            </stripes:option>
            <stripes:options-collection collection="${dataUtils.years}"/>
        </stripes:select>
    </td>
    <td>
        <div class="fielderror">
            <stripes:errors field="resume.year"/>
        </div>
    </td>
</tr>
<!--phone -->
<tr>
    <td>
        <stripes:label name="labelPhone"/>
    </td>
    <td>
        <stripes:text name="resume.phone"/>
    </td>
    <td>
        <div class="fielderror">
            <stripes:errors field="resume.phone"/>
        </div>
    </td>
</tr>

<!--sex -->
<tr>
    <td>
        <stripes:label name="labelSex"/>
    </td>
    <td>
        <stripes:select name="resume.sex">
            <stripes:option value="">
                <fmt:message key="page.createresume.choose"/>
            </stripes:option>
            <stripes:options-enumeration enum="ua.com.alus.resvac.crm.domen.prototype.SexType"/>
        </stripes:select>
    </td>
    <td>
        <div class="fielderror">
            <stripes:errors field="resume.sex"/>
        </div>
    </td>
</tr>

<!--salary -->
<tr>
    <td>
        <stripes:label name="labelSalary"/>
    </td>
    <td>
        <stripes:text name="resume.salary"/>
    </td>
    <td>
        <div class="fielderror">
            <stripes:errors field="resume.salary"/>
        </div>
    </td>
</tr>

<!-- Region -->
<tr>
    <td>
        <stripes:label name="labelRegion"/>
    </td>
    <td>
        <stripes:select id="region" name="resume.fkRegionId" onchange="invoke(this.form, this.name, 'city');">
            <stripes:option value="">
                <fmt:message key="page.createresume.choose"/>
            </stripes:option>
            <stripes:options-collection collection="${actionBean.baseService.regions}"
                                        label="name"
                                        value="id"/>
        </stripes:select>
    </td>
    <td>
        <div class="fielderror">
            <stripes:errors field="resume.fkRegionId"/>
        </div>
    </td>
</tr>

<!-- Region -->
<tr id="city">
    <td>
        <stripes:label name="labelPlace"/>
    </td>
    <td>
        <stripes:select name="resume.fkCityId">
            <stripes:option value="">
                <fmt:message key="page.createresume.choose"/>
            </stripes:option>
            <stripes:options-collection collection="${actionBean.cities}"
                                        label="name"
                                        value="id"/>
        </stripes:select>
    </td>
    <td>
        <div class="fielderror">
            <stripes:errors field="resume.fkCityId"/>
        </div>
    </td>
</tr>

<!--move -->
<tr>
    <td>
        <stripes:label name="labelMove"/>
    </td>
    <td>
        <stripes:checkbox name="resume.move"/>
    </td>
    <td>
        <div class="fielderror">
            <stripes:errors field="resume.move"/>
        </div>
    </td>
</tr>

<!--professional area -->
<tr>
    <td>
        <stripes:label name="labelProfessionalArea"/>
    </td>
    <td>
        <stripes:select name="resume.fkProfAreaUuid">
            <stripes:option value="">
                <fmt:message key="page.createresume.choose"/>
            </stripes:option>
            <stripes:options-collection collection="${actionBean.baseService.professionAreas}"
                                        label="name"
                                        value="uuid"/>
        </stripes:select>
    </td>
    <td>
        <div class="fielderror">
            <stripes:errors field="resume.fkProfAreaUuid"/>
        </div>
    </td>
</tr>

<!--position -->
<tr>
    <td>
        <stripes:label name="labelPosition"/>
    </td>
    <td>
        <stripes:text name="resume.position"/>
    </td>
    <td>
        <div class="fielderror">
            <stripes:errors field="resume.position"/>
        </div>
    </td>
</tr>
<!--startInLife -->
<tr>
    <td>
        <stripes:label name="labelStartInLife"/>
    </td>
    <td>
        <stripes:checkbox name="resume.startInLife"/>
    </td>
    <td>
        <div class="fielderror">
            <stripes:errors field="resume.startInLife"/>
        </div>
    </td>
</tr>
<!--citizenship -->
<tr>
    <td>
        <stripes:label name="labelSitizenShip"/>
    </td>
    <td>
        <c:forEach var="country" items="${dataUtils.countries}">
            <stripes:radio name="resume.citizenship" value="${country}"/>
            <stripes:label name="CitizenType.${country}"/>
            <br/>
        </c:forEach>
    </td>
    <td>
        <div class="fielderror">
            <stripes:errors field="resume.citizenship"/>
        </div>
    </td>
</tr>

<!-- file -->
<tr>
    <td>
        <stripes:label name="labelResumeUpload"/>
    </td>
    <td>
        <stripes:file name="resumeFile.fileBean"/>
    </td>
    <td>
        <div class="fielderror">
            <stripes:errors field="resumeFile.fileBean"/>
        </div>
    </td>
</tr>
</table>
<stripes:label name="labelAttachedFiles"/>
<br/>
<% int i = 0; %>
<c:forEach items="${requestScope.actionBean.resumeFilesUuid}" var="resumeFileUuid">
    <%= ++i + "."%>
    <stripes:link href="/resume/Resume.action?deleteResumeFile=&resumeUuid=${requestScope.actionBean.resume.uuid}&resumeFileUuid=${resumeFileUuid}"
            class="flowlink">
        <fmt:message key="delete"/>
    </stripes:link>
    <br/>
</c:forEach>
</div>
<stripes:submit name="saveResume"/>
</stripes:form>

</stripes:layout-component>

</stripes:layout-render>